<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		
	</head>
	<body>
			<table border="1" cellspacing="0" cellpadding="15px" id="tableId">
				<tr>
					<th></th>
					<th>姓名</th>
					<th>性别</th>
					<th>年龄</th>
					<th>家庭住址</th>
				</tr>
				<tr>
					<th><input type="checkbox" name="stu" id="" value="1" /></th>
					<th>张三1</th>
					<td>女</td>
					<td>19</td>
					<td>福建省新罗区</td>
				</tr>
				<tr>
					<th><input type="checkbox" name="stu" id="" value="2" /></th>
					<th>张三2</th>
					<td>男</td>
					<td>19</td>
					<td>福建省新罗区</td>
				</tr>
				<tr>
					<th><input type="checkbox" name="stu" id="" value="3" /></th>
					<th>张三3</th>
					<td>女</td>
					<td>19</td>
					<td>福建省新罗区</td>
				</tr>
				<tr>
					<th><input type="checkbox" name="stu" id="" value="4" /></th>
					<th>张三4</th>
					<td>男</td>
					<td>19</td>
					<td>福建省新罗区</td>
				</tr>
			</table>
			<td><input type="checkbox" name="" id="checkAllID" value="" onclick="checkall();" /></td>全选
			<td><input type="checkbox" name="" id="checkAllID2" value="" onclick="checkall2();" /></td>全选男
			<td><input type="checkbox" name="" id="checkAllID3" value="" onclick="checkall3();" /></td>全选女
			<button type="submit">删除</button>
			<!-- submit--提交到数据库 -->
	</body>
	<script type="text/javascript">
	var tableOjb = document.getElementById('tableId');
	var allSelInput = tableOjb.getElementsByTagName('input');
	var checkAllIDValue=document.getElementById('checkAllID');
	var checkAllIDValue2=document.getElementById('checkAllID2');
	var checkAllIDValue3=document.getElementById('checkAllID3');
	console.log(allSelInput[0].value);
		function checkall(){
			for(var i=0;i<allSelInput.length;i++){
				allSelInput[i].checked=checkAllIDValue.checked;
			}
		}
		function checkall2 () {
			for(var i=0;i<allSelInput.length;i++){
				if(allSelInput[i].value == '男'){
				allSelInput[i].checked = checkAllIDValue2.checked
				}
			}
		}
		function checkall2 () {
			for(var i=0;i<allSelInput.length;i++){
				if(allSelInput[i].value == '女'){
				allSelInput[i].checked = checkAllIDValue3.checked
				}
			}	
		}
	</script>
</html>
